package com.kaily.timemanager.db;

import android.provider.BaseColumns;

/**
 * Created by zhoulikai on 17/2/27.
 */

public class AppDatabase {

    /**
     * 任务类别表
     */
    public static abstract class TaskClassEntry implements BaseColumns {
        //任务类别表名
        public static final String TABLE_NAME = "TaskClassEntry_entry";
        //任务类别名称
        public static final String task_class_name = "task_class_name";
    }

    /**
     * 任务类表
     */
    public static abstract class TaskEntry implements BaseColumns {
        //任务表名
        public static final String TABLE_NAME = "TaskEntry_entry";
        //任务名称
        public static final String task_name = "task_name";
        //任务开始的时间
        public static final String task_start_time = "task_start_time";
        //任务结束的时间
        public static final String task_end_time = "task_end_time";

        //任务是否开启提醒
        public static final String task_remind_status = "task_remind_status";

        //任务完成状态
        public static final String task_do_status = "task_do_status";

        //任务所属的父任务
        public static final String task_parent_id = "task_parent_id";

        //任务的类型
        public static final String task_class_id = "task_class_id";

        //任务优先级
        public static final String task_priority = "task_priority";

        //任务标签
        public static final String task_label = "task_label";

        //任务标志（普通、循环任务）
        public static final String task_flag = "task_flag";

        //任务额外的字段
        public static final String task_extra = "task_extra";

    }


    /**
     * 想想(记事本)表结构
     */
    public static abstract class ThinkEntry implements BaseColumns {
        //记事本表名
        public static final String TABLE_NAME = "ThinkEntry";
        //标题
        public static final String think_title = "think_title";
        //内容
        public static final String think_content = "think_content";
        //创建时间
        public static final String think_create_time = "think_create_time";
    }

    public static abstract class Db {

        public final static String DBNAME = "AppDB";
        public final static int DBVERSION = 1;

        public static final String DB_PWD = "whoislcj";//数据库密码


        private static final String TEXT_TYPE = " TEXT";//TODO: test the integer type
        private static final String INTEGER_TYPE = " INTEGER";
        private static final String TIME_TYPE = " DATETIME DEFAULT CURRENT_TIMESTAMP";
        private static final String COMMA_SEP = ",";

        /**
         * 创建任务类别表
         */
        public static final String SQL_CREATE_TASK_CLASS_ENTRIES =
                "CREATE TABLE if not exists " + AppDatabase.TaskClassEntry.TABLE_NAME + " (" +
                        AppDatabase.TaskClassEntry._ID + " INTEGER PRIMARY KEY," +
                        AppDatabase.TaskClassEntry.task_class_name + TEXT_TYPE +
                        " )";
        /**
         * 任务类表
         */
        public static final String SQL_CREATE_TASK_ENTRIES =
                "CREATE TABLE if not exists " + AppDatabase.TaskEntry.TABLE_NAME + " (" +
                        AppDatabase.TaskEntry._ID + " INTEGER PRIMARY KEY," +
                        AppDatabase.TaskEntry.task_name + TEXT_TYPE + COMMA_SEP +
                        AppDatabase.TaskEntry.task_class_id + TEXT_TYPE + COMMA_SEP +
                        AppDatabase.TaskEntry.task_do_status + INTEGER_TYPE + COMMA_SEP +
                        AppDatabase.TaskEntry.task_end_time + INTEGER_TYPE + COMMA_SEP +
                        AppDatabase.TaskEntry.task_extra + TEXT_TYPE + COMMA_SEP +
                        AppDatabase.TaskEntry.task_flag + INTEGER_TYPE + COMMA_SEP +
                        AppDatabase.TaskEntry.task_label + TEXT_TYPE + COMMA_SEP +
                        AppDatabase.TaskEntry.task_parent_id + TEXT_TYPE + COMMA_SEP +
                        AppDatabase.TaskEntry.task_priority + INTEGER_TYPE + COMMA_SEP +
                        AppDatabase.TaskEntry.task_remind_status + INTEGER_TYPE + COMMA_SEP +
                        AppDatabase.TaskEntry.task_start_time + INTEGER_TYPE +
                        " )";

        /**
         * 创建想想（记事本）数据表
         */
        public static final String SQL_CREATE_THINK_ENTRIES =
                "CREATE TABLE if not exists " + AppDatabase.ThinkEntry.TABLE_NAME + " (" +
                        AppDatabase.ThinkEntry._ID + " INTEGER PRIMARY KEY," +
                        AppDatabase.ThinkEntry.think_title + TEXT_TYPE + COMMA_SEP +
                        AppDatabase.ThinkEntry.think_content + TEXT_TYPE + COMMA_SEP +
                        AppDatabase.ThinkEntry.think_create_time + INTEGER_TYPE +
                        " )";


        public static final String SQL_DELETE_TASK_CLASS_ENTRIES =
                "DROP TABLE IF EXISTS " + AppDatabase.TaskClassEntry.TABLE_NAME;

        public static final String SQL_DELETE_TASK_ENTRIES =
                "DROP TABLE IF EXISTS " + AppDatabase.TaskEntry.TABLE_NAME;

        public static final String SQL_DELETE_THINK_ENTRIES =
                "DROP TABLE IF EXISTS " + AppDatabase.ThinkEntry.TABLE_NAME;

    }

}
